
_vehicle = _this select 0;                              
_selectionName = _this select 1;
_damage = _this select 2;

diag_log format ["vehicleDamages: %1", _this];

_location = "";			
switch (_selectionName) do {
	case "": {
		// add the over-all structural damage value
        _location = "damage";
	};
    case "?" : {};
    default {
        _location = _selectionName;
    };
}; 

_varToSave = _vehicle getVariable "varToSaved";
if (!(_selectionName in _varToSave)) then {
    _varToSave set [count _varToSave, _selectionName];
}; 

_vehicle setVariable ["varToSaved", _varToSave];

_damage =  (parseNumber (_vehicle getVariable _selectionName)) + _damage;
_damageSTR = str(_damage);
_vehicle setVariable [_location, _damageSTR, true];

_this select 2 // return damage to engine to process.
     

// ====================================================================================